package battle.battleFightData
{
	public class BattleData implements XMLSerializable
	{
		private var _name:String;
		//攻击者
		private var _fighter:BattleAttackerData;
		//目标
		private var _target:BattleTargetData;
		//摄像机
		private var _camera:BattleCameraData;
		//效果
		private var _effect:BattleEffectData;
		//魔法
		private var _magic:BattleMagicData;
		//文字
		private var _texts:Vector.<BattleTextData>;
		
		//
		public function BattleData()
		{
			
		}
		
		public function get texts():Vector.<BattleTextData>
		{
			return _texts;
		}

		public function set texts(value:Vector.<BattleTextData>):void
		{
			_texts = value;
		}

		public function get magic():BattleMagicData
		{
			return _magic;
		}

		public function set magic(value:BattleMagicData):void
		{
			_magic = value;
		}

		public function get effect():BattleEffectData
		{
			return _effect;
		}

		public function set effect(value:BattleEffectData):void
		{
			_effect = value;
		}

		public function get camera():BattleCameraData
		{
			return _camera;
		}

		public function set camera(value:BattleCameraData):void
		{
			_camera = value;
		}

		public function get target():BattleTargetData
		{
			return _target;
		}

		public function set target(value:BattleTargetData):void
		{
			_target = value;
		}

		public function get fighter():BattleAttackerData
		{
			return _fighter;
		}

		public function set fighter(value:BattleAttackerData):void
		{
			_fighter = value;
		}

		public function get name():String
		{
			return _name;
		}

		public function set name(value:String):void
		{
			_name = value;
		}

		public function toXml():XML
		{
			return null;
		}
		
		public function fromXml(xml:XML):void
		{
			//trace(xml.toXMLString());
			if(xml.hasOwnProperty("fighter"))
			{
				_fighter = new BattleAttackerData();
				_fighter.fromXml(xml.fighter[0]);
			}
			if(xml.hasOwnProperty("target"))
			{
				_target = new BattleTargetData();
				_target.fromXml(xml.target[0]);
			}
			if(xml.hasOwnProperty("camera"))
			{
				_camera = new BattleCameraData();
				_camera.fromXml(xml.camera[0]);
			}
			if(xml.hasOwnProperty("effect"))
			{
				_effect = new BattleEffectData();
				_effect.fromXml(xml.effect[0]);
			}
			if(xml.hasOwnProperty("fmagic"))
			{
				_magic = new BattleMagicData();
				_magic.fromXml(xml.fmagic[0]);
			}
			if(xml.hasOwnProperty("text"))
			{
				_texts = new Vector.<BattleTextData>();
				for each(var txt:XML in xml.text)
				{
					var txtTemp:BattleTextData = new BattleTextData();
					txtTemp.fromXml(txt);
					_texts.push(txtTemp);
				}
			}
		}
		
	}
}